<template>
	<view class="page">
		<!-- 文章数据 -->
		<mescroll-body ref="mescrollRef" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption"
			:top="0">
			<view class="article-data">
				<view class="article-list">
					<view class="list" v-for="(item, index) in typeOfEntry" :key="item.id">
						<view class="thumb">
							<image :src="item.icon_url"></image>
						</view>
						<view class="item">
							<view class="title">
								{{ item.name }}
							</view>
							<view class="titleRight">
								<view class="thumb" v-if="index === 0" @click="callPhone">
									<u-icon name="phone-fill" color="#fff" size="32"></u-icon>
								</view>
								<text class="two-omit" v-else @click="onArticle(item.id, item.name)">去入驻</text>
							</view>
						</view>
					</view>
				</view>
			</view>
		</mescroll-body>
		<u-popup :show="qrcode" round="10" mode="center" @close="qrcode=false" >
			<view style="margin: 20rpx;">
				<image :src="qrcodeImg" mode="widthFix" ></image>
			</view>
		</u-popup>
	</view>
</template>

<script>
	// 引入mescroll-mixins.js
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	import {
		getQrCodeShichang,
	} from '@/config/api.js';
	export default {
		mixins: [MescrollMixin], // 使用mixin
		components: {},
		data() {
			const navList = uni.getStorageSync('navList');
			const userInfo = uni.getStorageSync('userInfo');
			return {
				mescroll: null, // mescroll实例对象 (此行可删,mixins已默认)
				// 下拉刷新的配置(可选, 绝大部分情况无需配置)
				downOption: {},
				// 上拉加载的配置(可选, 绝大部分情况无需配置)
				upOption: {},
				qrcodeImg: '',
				qrcode:false,
				userInfo,
				shicahngId:false,
				typeOfEntry: [{
					'id': 0,
					'name': '平台客服'
				}].concat(navList),
			};
		},
		onLoad(query) {
			const scene = decodeURIComponent(query.scene);
			if(scene){
				this.shicahngId = scene.split('shichangId=')[1];
				uni.setStorageSync('_LOADSCID',this.shicahngId);
			}else{
				uni.setStorageSync('_LOADSCID','');
			}
		},
		methods: {
			showQrcode(){
				getQrCodeShichang().then(res => {
					this.qrcodeImg = res;
					this.qrcode = true;
				})
			},
			callPhone() {
				uni.makePhoneCall({
					phoneNumber: '114' //仅为示例
				});
			},
			/*下拉刷新的回调, 有三种处理方式:*/
			downCallback() {
				this.mescroll.endSuccess();
			},
			/*上拉加载的回调*/
			upCallback(page) {
				setTimeout(() => {
					this.mescroll.endByPage(10, 20);
				}, 2000)
			},
			/**
			 * 入住点击
			 */
			onArticle(typeId, title) {
				if(typeId == 2 && this.userInfo.isAttract){
					return this.showQrcode();
				}
				let tourl = '';
				// 根据 typeId 跳转到不同的页面
				console.log('哈哈哈', typeId)
				switch (typeId) {
					case 0:

						break;
					case 1:
						// 跳转到招商经理页面
						 tourl =  `/moduleA/MerchantIn/boWuGuan/boWuGuan?title=${encodeURIComponent(title)}&nav_id=${typeId}`;
						if(this.shicahngId){
							tourl += '&zhaoshang_id='+this.shicahngId
						}
						uni.navigateTo({
							url: tourl,
						});
						break;
					case 2:
						// 跳转到市场区域代理页面
						
						uni.navigateTo({
							url: '/moduleA/MerchantIn/zhaoShanJingLi/zhaoShanJingLi',
						});
						break;
					case 3:
						 tourl = '/moduleA/MerchantIn/quYuDaiLi/quYuDaiLi?nav_id=' + typeId;
						if(this.shicahngId){
							tourl += '&zhaoshang_id='+this.shicahngId
						}
						uni.navigateTo({
							url: tourl, // 请替换为实际路径
						});
						break;
					case 4:
					case 5:
					case 6:
					case 7:
					case 8:
					case 13:
						// 跳转到全国私人博物馆页面
						tourl = `/moduleA/MerchantIn/boWuGuan/boWuGuan?title=${encodeURIComponent(title)}&nav_id=${typeId}`;
						if(this.shicahngId){
							tourl += '&zhaoshang_id='+this.shicahngId
						}
						uni.navigateTo({
							url: tourl,
						});
						break;
					case 9:
						// 跳转到全球名人书画家页面
						tourl =  `/moduleA/MerchantIn/shuHuaJia/shuHuaJia?title=${encodeURIComponent(title)}&nav_id=${typeId}`;
						if(this.shicahngId){
							tourl += '&zhaoshang_id='+this.shicahngId
						}
						uni.navigateTo({
							url: `/moduleA/MerchantIn/shuHuaJia/shuHuaJia?title=${encodeURIComponent(title)}&nav_id=${typeId}`, // 请替换为实际路径
						});
						break;
					case 10:
						// 跳转到评估鉴定师页面
						tourl = `/moduleA/MerchantIn/jianDingShi/jianDingShi?title=${encodeURIComponent(title)}&nav_id=${typeId}`;
						if(this.shicahngId){
							tourl += '&zhaoshang_id='+this.shicahngId
						}
						uni.navigateTo({
							url: tourl, // 请替换为实际路径
						});
						break;
					case 11:
						// 跳转到拍卖公司页面
						tourl = `/moduleA/MerchantIn/paiMaiGongSi/paiMaiGongSi?title=${encodeURIComponent(title)}&nav_id=${typeId}`;
						if(this.shicahngId){
							tourl += '&zhaoshang_id='+this.shicahngId
						}
						uni.navigateTo({
							url: tourl, // 请替换为实际路径
						});
						break;
					case 12:
						// 跳转到评估鉴定机构页面
						tourl = `/moduleA/MerchantIn/pingGujianDing/pingGujianDing?title=${encodeURIComponent(title)}&nav_id=${typeId}`;
						if(this.shicahngId){
							tourl += '&zhaoshang_id='+this.shicahngId
						}
						uni.navigateTo({
							url: tourl, // 请替换为实际路径
						});
						break;
						// case 13:
						// 	// 跳转到360行行业商户页面
						// 	uni.navigateTo({
						// 		url: `/moduleA/MerchantIn/360hang/boWuGuan?title=${encodeURIComponent(title)}&nav_id=${typeId}`, // 请替换为实际路径
						// 	});
						// 	break;
					default:
						console.log('未定义的类型');
						break;
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	@import 'MerchantIn.scss';
</style>